package com.lz.gmall.product.controller;

import com.lz.gmall.common.result.Result;
import com.lz.gmall.common.result.ResultCodeEnum;
import com.lz.gmall.product.entity.BaseAttrValue;
import com.lz.gmall.product.service.BaseAttrValueService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/admin/product")
@Api("平台属性值操作")
public class AttrValueController {

    @Autowired
    private BaseAttrValueService baseAttrValueService;

    /**
     * 根据平台属性ID获取平台属性对象数据（平台属性值）
     * 用于数据回显
     * @param attrId 平台属性id
     * @return 平台属性值集合
     */
    @GetMapping("/getAttrValueList/{attrId}")
    @ApiOperation("根据属性id回显属性值")
    public Result<List<BaseAttrValue>> getAttrValueList(@PathVariable(value = "attrId") Long attrId){
        List<BaseAttrValue> baseAttrValueList = baseAttrValueService.getAttrValueList(attrId);
        return Result.build(baseAttrValueList, ResultCodeEnum.SUCCESS);
    }
}
